<style lang='less' >
  .ppBtnBox{
    #btnsBox{
      text-align: left;
      button{
        background-color: transparent;
        color:#63c5ce;
        font-size: 14px;
        padding:0 10px;
        border-right: 1px solid #63c5ce;
        border-radius: 0;
        &:last-child{
          border:none;
        }
      }
      .fontColorGary{
        color: #bbb;
      }
    }
    .el-dialog__wrapper{
      text-align: left;
      .el-dialog{
        width: 30%;

        .el-dialog__header{
          
          background-color: #f6f6f6;
          padding: 10px;
          border-radius: 2px 2px 0 0;
        }
        .el-dialog__body{
          padding: 30px 50px 20px;
          .el-form-item__label{
            text-align: center;
          }
        }
      }

    }
  }
</style>

<template>
  <div class="ppBtnBox">

    <div id='btnsBox'>
      <button v-if='btnControl && btnControl.check' @click='clickBtn("Check",scope.$index, scope.row)'>查看</button>
      <button v-if='btnControl && btnControl.edit'  :class='{fontColorGary: false}' @click='clickBtn("Edit",scope.$index, scope.row)'>修改</button>
      <button v-if='btnControl && btnControl.changeStatus' @click='changeStatus(scope.$index, scope.row)'>更改状态</button>
      <button v-if='btnControl && btnControl.copy ' :class='{fontColorGary:false}'@click='copyProduct(scope.$index, scope.row)'>一键复制</button>
    </div>

    <change-status-box
    v-if='dialogFormVisible'
    :dialogFormVisible='dialogFormVisible'
    :dialogInfo='scope.row'
    v-on:reloadPage='reloadPage'
    v-on:handleDialog='handleDialog'
    v-on:setChangeStatus='setChangeStatus'
    ></change-status-box>
    
    
  </div>
</template>

<script>
  import ChangeStatusBox from './handle/changeStatus.vue'
  import {postPPCopy} from 'api/privatePlacement/index.js'
  export default {
    props:['btnControl','scope'],
    components:{
      ChangeStatusBox,
    },
    data(){
      return{
        dialogFormVisible:false,//更改状态的弹出框
      }
    },
    computed:{
    },
    methods:{
      clickBtn(classes,index, row){
        let name = 'privatePlacementList' + classes
        console.log(classes, name, index, row)
        this.goPage(name, row.id)
      },
      reloadPage(){
        this.$emit('reloadPage')
        this.dialogFormVisible = false;

      },
      changeStatus(index, row){
        console.log('changeStatus', index, row)
        this.dialogFormVisible= true
      },
      handleDialog(){
        this.dialogFormVisible = false;

      },
      setChangeStatus(e){
        console.log('setChangeStatus', e)
        
      },
      copyProduct(index, row){
        console.log('copyProduct', index, row)
        this.postPPCopy(row.id)
      },
      async postPPCopy(id){
        try{
          let params ={
            productId:id
          }
          let back = await postPPCopy(params)
          back = back.data;
          console.log('postPPCopy', back)
          if(back && back.resultCode =='200'){
            this.$alert(back.msg,{
              callball:action =>{
                this.$emit('reloadPage')
              }
            })
          }else{
            this.$alert(back.msg)
          }
          
        }catch(err){
          console.error(err)
        }
      },
      goPage(name, id){
        console.log()
        this.$router.push({
          name:name,
          query:{
            productId:id
          }
        })
      }
    },
    created(){

    },
    mounted(){

    },
  }
</script>